<?php

class Category extends Controller {

	function Category()
	{
		parent::Controller();
		$this->load->helper('admin');
	}
	
	function index()
	{
		echo 'yay';
	}
	
	function cat() {
		
		//get the theme
		$theme = $this->Settings_Model->get_theme();
		
		//get the pages for the sidebar
		$data['pages'] = $this->Pages_Model->get_all_pages();
		$data['categories'] = $this->Categories_Model->get_hierarchy();
		$data['parentid'] = $this->uri->segment(3);
		
		$thiscat = $this->Categories_Model->get_category_title_and_description($this->uri->segment(3));
		
		$data['location'] = 'category';
		
		$data['title'] = $thiscat->title;
		
		//category description
		$data['content'] = '<p>' . $thiscat->description . '</p>';
		
		//some items
		$data['content'] .= 'ITEMS GO HERE';
		
		$this->load->view('themes/' . $theme . '/index', $data);
		
		
	}
	
	function acat() {
		//ajaxy
		
		//items from this category on the left
		$cat = $this->Categories_Model->get_category_title_and_description($this->uri->segment(3));
		echo '<h2>' . $cat->title . '</h2>';
		echo '<p>' . $cat->description . '</p>';
		
		//now for some items
		echo "ITEMS HERE";
	}
	
	function acatlist() {
		
		$parentid = $this->uri->segment(3);
		
		//get categories
		$categories = $this->Categories_Model->get_hierarchy();
		
		//ajaxy
		echo '<li>^ <a href="';
		echo base_url();
		echo 'index.php/">Top Level</a></li>';
		foreach ($categories as $category) { 
			if ($category->parentid == $parentid) {
				echo '<li class="productsmenu cat';
				echo $category->catid;
				echo '">&raquo; <a href="';
				echo base_url();
				echo 'index.php/category/cat/';
				echo $category->catid;
				echo '">';
				echo $category->catname;
				echo '</a></li>';
			}
		}
	}
	
	
}
?>